#define _CRT_SECURE_NO_WARNINGS 1
class Solution {
public:
    vector<vector<int>> ret;
    vector<int> path;
    void dfs(vector<int>& nums, int n) {
        ret.push_back(path);
        for (int i = n; i < nums.size(); i++) {
            path.push_back(nums[i]);
            dfs(nums, i + 1);
            path.pop_back();
        }
    }
    int add(vector<int>& v) {
        int sum = 0;
        for (auto e : v) {
            sum ^= e;
        }
        return sum;
    }
    int subsetXORSum(vector<int>& nums) {
        dfs(nums, 0);
        int sum = 0;
        for (int i = 0; i < ret.size(); i++) {
            sum += add(ret[i]);
        }
        return sum;
    }
};